package cn.schoolwow.workflow.test.module.analyzeWorkReport.query.testcase;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.workflow.QuickWorkFlow;
import cn.schoolwow.workflow.entity.WorkFlowInstance;
import com.alibaba.fastjson.JSONObject;
import org.junit.Assert;

public class UpdateWorkFlowInstanceContextTestCaseFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        QuickWorkFlow quickWorkFlow = flowContext.checkInstanceData(QuickWorkFlow.class);
        WorkFlowInstance workFlowInstance = flowContext.checkInstanceData(WorkFlowInstance.class);

        workFlowInstance.getContextData().put("新增属性", "123456");
        quickWorkFlow.updateWorkFlowInstanceContextData(workFlowInstance.getId(), workFlowInstance.getContextData());

        JSONObject contextData = quickWorkFlow.getWorkFlowInstanceContextData(workFlowInstance.getId());
        Assert.assertTrue(contextData.containsKey("新增属性"));
        Assert.assertEquals("123456", contextData.getString("新增属性"));
    }

    @Override
    public String name() {
        return "分析工作报告-更新实例上下文数据-测试用例";
    }
}
